<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ASCII to AFSK Wave</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
        }
        .parameter-group {
            margin-bottom: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 5px;
        }
        .parameter-group h3 {
            margin-top: 0;
            color: #495057;
        }
        .param-row {
            display: flex;
            align-items: center;
            margin-bottom: 10px;
        }
        .param-row label {
            width: 150px;
            font-weight: bold;
        }
        .param-row input {
            flex: 1;
            padding: 5px 10px;
            border: 1px solid #ddd;
            border-radius: 3px;
            margin-right: 10px;
        }
        .param-row .unit {
            width: 40px;
            color: #666;
        }
        #textInput {
            width: 100%;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-family: monospace;
            resize: none;
        }
        .button-group {
            text-align: center;
            margin-top: 20px;
        }
        button {
            padding: 10px 20px;
            margin: 0 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #0056b3;
        }
        button:disabled {
            background-color: #6c757d;
            cursor: not-allowed;
        }
        #status {
            text-align: center;
            margin-top: 15px;
            padding: 10px;
            border-radius: 5px;
        }
        .status-info {
            background-color: #d1ecf1;
            color: #0c5460;
        }
        .status-success {
            background-color: #d4edda;
            color: #155724;
        }
        .status-error {
            background-color: #f8d7da;
            color: #721c24;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>ASCII to AFSK Wave 调制器</h1>
        
        <div class="parameter-group">
            <h3>AFSK 参数设置</h3>
            <div class="param-row">
                <label for="fSample">采样频率:</label>
                <input type="number" id="fSample" value="16000" min="8000" max="48000" step="1000">
                <span class="unit">Hz</span>
            </div>
            <div class="param-row">
                <label for="fSpace">空间频率 (0):</label>
                <input type="number" id="fSpace" value="1500" min="300" max="3000" step="100">
                <span class="unit">Hz</span>
            </div>
            <div class="param-row">
                <label for="fMark">标记频率 (1):</label>
                <input type="number" id="fMark" value="1800" min="300" max="3000" step="100">
                <span class="unit">Hz</span>
            </div>
            <div class="param-row">
                <label for="bitRate">比特率:</label>
                <input type="number" id="bitRate" value="100" min="50" max="1000" step="50">
                <span class="unit">bps</span>
            </div>
            <div class="param-row">
                <label for="amplitude">信号幅度:</label>
                <input type="number" id="amplitude" value="0.3" min="0.1" max="1.0" step="0.1">
                <span class="unit"></span>
            </div>
            <div class="param-row">
                <label for="attackBits">前导载波位数:</label>
                <input type="number" id="attackBits" value="6" min="4" max="64" step="4">
                <span class="unit">bits</span>
            </div>
            <div class="param-row">
                <label for="checksum">校验和:</label>
                <input type="text" id="checksum" value="0x00" readonly style="background-color: #f8f9fa; color: #6c757d;">
                <span class="unit">hex</span>
            </div>
        </div>

        <div class="parameter-group">
            <h3>输入文本</h3>
            <textarea id="textInput" placeholder="请输入要转换的文本... (仅支持ASCII字符)" rows="4"></textarea>
        </div>

        <div class="button-group">
            <button id="generateButton">生成音频</button>
            <button id="playButton" disabled>播放</button>
            <button id="loopButton" disabled>循环</button>
            <button id="stopButton" disabled>停止</button>
            <button id="downloadButton" disabled>下载WAV</button>
        </div>

        <div id="status"></div>
    </div>

    <script src="script.js"></script>
</body>
</html>